const mongoose = require('mongoose')
const md5 = require('../utils/md5')

const userSchema = new mongoose.Schema({
    username: {
        type: String,
        required: true,
    },
    password: {
        type: String,
        required: true,
        set: value => md5(value),
        select: false
    },
    email: {
        type: String,
        required: true,
        unique: true
    },
    avatar: {
        type: String,
        default: 'https://api.adorable.io/avatars/285/default.png'
    },
    createdAt: {
        type: Date,
        default: Date.now
    },
    friendList:{
        type:Array,
        default:[]
    }
})

module.exports = userSchema